<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>公司列表管理</title>
<!-- 引入layui的样式文件和脚本文件 -->
<link rel="stylesheet" type="text/css" href="../layui/css/layui.css" />
<script src="../layui/layui.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>

	<div id="updDiv">
		<form class="layui-form" lay-filter="companyform" id="updateForm">
			<!-- 提示：如果你不想用form，你可以换成div等任何一个普通元素 -->
			<div class="layui-form-item">
				<label class="layui-form-label">id</label>
				<div class="layui-input-inline">
					<input type="text" name="id" placeholder="请输入公司编号"
						autocomplete="off" class="layui-input  layui-disabled" required
						lay-verify="required">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">名称</label>
				<div class="layui-input-inline">
					<input type="text" name="comname" placeholder="请输入公司名称"
						autocomplete="off" class="layui-input" required
						lay-verify="required">
				</div>
			</div>
			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label">公司评价</label>
				<div class="layui-input-block">
					<textarea placeholder="请输入公司评价" class="layui-textarea"
						name="detail" autocomplete="off" class="layui-input" required
						lay-verify="required"></textarea>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">招商</label>
				<div class="layui-input-block">
					<input type="text" name="zhaoShang" placeholder="请输入公司招商"
						autocomplete="off" class="layui-input" required
						lay-verify="required">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">电话</label>
				<div class="layui-input-block">
					<input type="text" name="tel" placeholder="请输入公司电话"
						autocomplete="off" class="layui-input" required
						lay-verify="required">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">地址</label>
				<div class="layui-input-block">
					<input type="text" name="address" placeholder="请输入公司地址"
						autocomplete="off" class="layui-input" required
						lay-verify="required">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">邮箱</label>
				<div class="layui-input-block">
					<input type="text" name="email" placeholder="请输入公司邮箱"
						autocomplete="off" class="layui-input" required
						lay-verify="required">
				</div>
			</div>
			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label">文化</label>
				<div class="layui-input-block">
					<!-- <textarea placeholder="请输入公司文化" class="layui-textarea" name="culture" autocomplete="off" class="layui-input" required
						lay-verify="required"></textarea> -->
					<div id="div1" name="culture"></div>
				</div>
			</div>
			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label">简介</label>
				<div class="layui-input-block">
					<textarea placeholder="请输入公司简介" class="layui-textarea"
						name="jianjie" autocomplete="off" class="layui-input" required
						lay-verify="required"></textarea>
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">x</label>
				<div class="layui-input-block">
					<input type="text" name="x" placeholder="请输入公司x轴地标"
						autocomplete="off" class="layui-input" required
						lay-verify="required">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">y</label>
				<div class="layui-input-block">
					<input type="text" name="y" placeholder="请输入公司y轴地标"
						autocomplete="off" class="layui-input" required
						lay-verify="required">
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn" lay-submit lay-filter="formDemo2">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>
	</div>
	<!-- 修改的弹窗结束 -->


	<!-- 脚本开始 -->
	<script type="text/javascript" src="../js/wangEditor.min.js"></script>
	<script>
		layui.use([ 'form', 'layer' ], function() {
			var form = layui.form;
			var layer = layui.layer;
			var $ = layui.$;

			var E = window.wangEditor
			var editor = new E('#div1')
			// 或者 var editor = new E( document.getElementById('editor') )
			editor.create()
			
			$.post("ComdeServletAdmin?method=getComdeList", function(res) {
				form.val("companyform", res.data);
				editor.txt.html(res.data.culture);//表单回显数据
			}, "json")

			//监听表单提交--修改
			form.on('submit(formDemo2)', function(data) {
				
				//动态的向表单添加数据
				data.field.culture=editor.txt.html();
				var url = "ComdeServletAdmin?method=updateComde";
				//var str = $("#updateForm").serialize();//请求参数，表单中的数据，serialize序列化
				//ajax请求服务器，判断结果
				$.post(url, data.field, function(res) {
					console.log(res);
					if (res) {
						layer.open({
							type : 1,
							btn : "确定",
							content : '修改成功'//这里content是一个普通的String
						})

					} else {
						layer.open({
							type : 1,
							btn : "确定",
							content : '修改失败'//这里content是一个普通的String
						});
					}
					if (res.code == 0) {
						layer.msg(res.mag, {
							time : 1000
						}, function() {
							layer.closeAll();//关闭所有窗口
						})
					}
				}, "json")
				return false;
			});

		});
	</script>
</body>
</html>